﻿using HrEFCore;
using HrIService;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HrService
{
	public class CPCService : ICPCService
	{
		private readonly MyDbContext myDbContext;

		public CPCService(MyDbContext myDbConext)
		{
			this.myDbContext = myDbConext;
		}
		//添加
		public async Task<int> AddCPCAsync(CPC cpc)
		{
			myDbContext.CPC.Add(cpc);
			return await myDbContext.SaveChangesAsync();
		}

        public async Task<int> AddPay(CPC cpc)
        {
            //添加薪酬
            cpc.AttributeKind = "薪酬设置";
            myDbContext.CPC.Add(cpc);
            return await myDbContext.SaveChangesAsync();
        }

        //查询所有
        public Task<List<CPC>> CPCAllAsync()
		{
			return myDbContext.CPC.ToListAsync();
		}
		//删除
		public async Task<int> DeleteCPCAsync(short id)
		{
			var zhi = await myDbContext.CPC.FindAsync(id);
			if (zhi == null)
			{
				return 0;
			}
			myDbContext.CPC.Remove(zhi);
			return await myDbContext.SaveChangesAsync();
		}

        public async Task<List<CPC>> InquireJobTitle()
        {
            //根据AttributeKind的值->职称,查询AttributeName的值
            string attributeKind = "职称"; // 设置要查询的属性种类
            var result = await myDbContext.CPC
                .Where(c => c.AttributeKind == attributeKind)
                .Select(c => new CPC { AttributeName = c.AttributeName , PbcId =c.PbcId }) // 仅选择需要的属性
                .ToListAsync();
            return result;
        }

        public async Task<List<CPC>> InquirePay()
        {
            //根据AttributeKind的值是薪酬设置，查询AttributeName的值
            string attributeKind = "薪酬设置"; // 设置要查询的属性种类
            var result = await myDbContext.CPC
                .Where(c => c.AttributeKind == attributeKind)
                .Select(c => new CPC { AttributeName = c.AttributeName , PbcId = c.PbcId }) // 仅选择需要的属性
                .ToListAsync();
            return result;
        }
		public async Task<List<CPC>> Inquirenationnal()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "国籍"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireNation()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "民族"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireZjxy()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "宗教信仰"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireZzmm()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "政治面貌"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireJynx()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "教育年限"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> Inquirexl()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "学历"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireZy()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "专业"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireTc()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "特长"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireAh()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "爱好"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquirePxxm()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "培训项目"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquirePxcj()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "培训成绩"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireJlxm()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "奖励项目"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
		public async Task<List<CPC>> InquireJldj()
		{
			//根据AttributeKind的值是薪酬设置，查询AttributeName的值
			string attributeKind = "奖励等级"; // 设置要查询的属性种类
			var result = await myDbContext.CPC
				.Where(c => c.AttributeKind == attributeKind)
				.Select(c => new CPC { AttributeName = c.AttributeName, PbcId = c.PbcId }) // 仅选择需要的属性
				.ToListAsync();
			return result;
		}
	}
}
